package modules.lobby.view
{
	import flash.display.Bitmap;
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.utils.getTimer;

	import modules.ViewManager;

	public class JackpotNumViewManager extends ViewManager
	{
		private var mainUI:MovieClip;

		private var jackpotNumImg:Bitmap;

		public var showNumber:Number;

		public function JackpotNumViewManager(mainUI:MovieClip)
		{
			this.mainUI = mainUI;

			init();
		}

		override protected function init():void
		{
			jackpotNumImg = new Bitmap();
			mainUI.numberMC.addChild(jackpotNumImg);

			mainUI.addEventListener(Event.ADDED_TO_STAGE, onAddToStage);
			mainUI.removeEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage);
		}

		override protected function onAddToStage(event:Event):void
		{
			mainUI.addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}

		override protected function onRemovedFromStage(event:Event):void
		{
			mainUI.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
		}

		protected function onEnterFrame(event:Event):void
		{
			showNumber = getTimer() / 100 + 100000;
			updateView();
		}

		override protected function updateView():void
		{
			jackpotNumImg.bitmapData = JackPotNumber.getJackPotNumber("RMB", showNumber);
			jackpotNumImg.x = (jackpotNumImg.parent.width - jackpotNumImg.width) / 2;
			jackpotNumImg.y = (jackpotNumImg.parent.height - jackpotNumImg.height) / 2;
		}
	}
}
